exports.findWithPageInfo = co.wrap(function*(Col, find_query, num, page, options) {
	num = parseInt(num, 10) || 20;
	page = parseInt(page, 10) || 0;
	options || (options = {});

	var cursor = Col.find(find_query).limit(num).skip(num * page).sort(["createTime", -1]);

	if (options.project) {
		cursor.project(options.project)
	}

	cursor.sort(options.sort || ["createTime", -1]);


	const res = yield {
		total_num: Col.count(find_query),
		data: populateList(Col, cursor.toArray()),
		page: page,
		num: num,
	};
	res.total_page = res.total_num ? Math.ceil(res.total_num / num) : 1;

	return res;
});


exports.populateList = populateList;

function populateList(Col, find_promise) {
	return find_promise.then(co.wrap(function*(list) {
		return yield list.map(item => socket.mongodbPupulateAll(item));
	}));
};